<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.jiabonet.DB.staticBean"%>
<%
String path = request.getContextPath();
String Admin = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+staticBean.getAdminDir();
%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>更改帐号基本信息</title>
<link href="<%=path%>/Public/css/AdminCss.css" rel="stylesheet" type="text/css" />
<script src="<%=path%>/Public/js/jquery.min.js" type="text/javascript"></script>
<!--<script src="<%=path%>/Public/js/jquery.form.js"></script>-->
<script type="text/javascript">
$(function(){		
	$("#tables tr").hover(
	  function () {
		$(this).css("background","#d5f4fe");
	  },
	  function () {
		$(this).css("background","#fff");
	  }
	);

	var send = $("input[name='send']");
	var password = $("#PassWord");
	var notpassword = $("#NotPassWord");
	var name = $("input[id='Name']");
	var Content = $("#Content");
	name.blur(function (){
		if(name.val().length<=0){
			$("#IsName").show();
			$("#IsName1").html("<font color=red>用户名格式错误，请重新输入!</font>");
			return false;
		}				
	
	});

	Content.blur(function (){
		if(Content.val().length>500){
			alert("备注说明太多，请删除一些！");
			return false;
		}
	});
	
	password.blur(function (){
		if(password.val().length>0){
				if(isPassWord(password.val())){
					$("#IsPassWord").show();
					$("#IsPassWord1").html("<font color=#69D172>密码格式正确!</font>");
					return true;
				}else{
					$("#IsPassWord").show();
					$("#IsPassWord1").html("<font color=red>密码格式错误，请重新输入!</font>");
					$("#IsNotPassWord").show();
					$("#IsNotPassWord1").html("<font color=red>两次密码不一致，请重新输入!</font>");
					return false;
				}				
		}
	});
	notpassword.blur(function (){
		if(password.val().length>0){
			if(notpassword.val()==password.val() || notpassword.val().length==password.val().length){
				$("#IsNotPassWord").show();
				$("#IsNotPassWord1").html("<font color=#69D172>密码格式正确!</font>");
				return true;
			}else{
				$("#IsNotPassWord").show();
				$("#IsNotPassWord1").html("<font color=red>两次密码不一致，请重新输入!</font>");
				return false;
			}
		}
	});
	
	send.click(function(){
		var Id = $("input[name='Id']").val();	
		var passwords = password.val();	
		var names = name.val();	
		var state = $("input:checked").val();	
		if(state=="on"){ state=1; }else{ state=0; }
		var level = $("select option:selected").val();	
		if(passwords.length>0){
			if(passwords.length<6){
				$("#IsPassWord").show();
				$("#IsPassWord1").html("<font color=red>密码格式错误，请重新输入!</font>");
				$("#IsSend").show();
				$("#IsSend1").html("<font color=red>密码格式错误，请重新输入!</font>");
				return false;
			}
		}
		$.ajax({
			   type: "POST",
			   url: "<%=path%>/Staff!Staff_Update.action?T="+Math.random(),
			   data: "staff.Content="+Content.val()+"&staff.Name="+names+"&staff.Id="+Id+"&staff.Password="+passwords+"&staff.State="+state+"&staff.Level="+level,
			   success: function(msg){
				   if(msg.isOK==1){
					  	$("#IsSend").show();
					  	$("#IsSend1").html(msg.returnInfo).css("color","#69D172");
				   }else{
					   	$("#IsSend").show();
					  	$("#IsSend1").html(msg.returnInfo).css("color","red");
				   }
			   }
		});
		
	});
});
function isUserName(str) {  
	var result = str.match(/^[a-z][a-z0-9_]{2,}$/i);   
    if (result == null)  
        return false;          
    return true;
}

function isPassWord(str) {  
	var result = str.match(/^[a-zA-Z0-9_\!\@\.]{5,}$/);   
    if (result == null)  
        return false;
    return true;
} 
</script>


</head>
<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="24" bgcolor="#353c44"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
          <td>
			<table width="100%" border="0" cellspacing="0"
				cellpadding="0">
				<tr>
					<td width="6%" height="24" valign="center">
						<div align="center">
							<img src="<%=Admin %>/images/tb.gif" width="14" height="14" />
						</div>
					</td>
					<td width="94%" height="24" valign="center">
						<span class="STYLE1"> <strong>更改帐号基本信息</strong>
						</span>
					</td>
				</tr>
			</table>
		</td>
            <td><div align="right"><span class="STYLE1">
              &nbsp;&nbsp;<img src="<%=Admin %>/images/edit.gif" width="10" height="10" /> 当前用户：<%=session.getAttribute("Username") %>   &nbsp;</span><span class="STYLE1"> &nbsp;</span></div></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td>
    <s:iterator value="Users" id="contents">
    <table width="100%" border="0" cellpadding="0" cellspacing="1"
		bgcolor="#a8c7ce" id="tables">
		<tr height="30">
			<td width="14%" bgcolor="d3eaef" class="STYLE6">
				<div align="center">
					<span class="STYLE10">员工名称：</span>
				</div>
			</td>
			<td width="34%" bgcolor="d3eaef" class="STYLE6">
				<div align="left">
					<span class="STYLE10" style="margin-left: 15px;">
					<input type="text" value="<s:property value="#contents.Name"/>" name="staff.Name" id="Name" maxlength="32" size="24"/>
					<input type="hidden" value="<%=request.getRemoteAddr() %>" name="Ip" maxlength="32" size="24"/>
					<input type="hidden" value="<s:property value="#contents.Id"/>" name="Id"/>
					</span>
				</div>
			</td>
			<td width="52%" bgcolor="d3eaef" class="STYLE6">
				<div align="left">
					<span class="STYLE10" style="margin-left: 15px;">（员工名称为真实姓名）</span>
				</div>
			</td>
		</tr>
		<tr bgcolor="#ffffff" height="30" id="IsName" style="display:none;">
			<td colspan="3" bgcolor="#ffffff" class="STYLE6">
				<div align="left" style="padding-left: 50px;">
					<span class="STYLE10" id="IsName1">
					</span>
				</div>
			</td>
		</tr>
		<tr bgcolor="#ffffff" height="30">
			<td width="14%" class="STYLE6">
				<div align="center">
					<span class="STYLE10">登录名称：</span>
				</div>
			</td>
			<td width="34%" class="STYLE6">
				<div align="left">
					<span class="STYLE10" style="margin-left: 15px;">
					 <s:property value="#contents.Username"/>
					<input type="hidden" value="<%=request.getRemoteAddr() %>" name="Ip" maxlength="32" size="24"/>
					</span>
				</div>
			</td>
			<td width="52%"  class="STYLE6">
				<div align="left">
					<span class="STYLE10" style="margin-left: 15px;">（用户名不允许更改，用来登录与管理）</span>
				</div>
			</td>
		</tr>
		<tr bgcolor="#ffffff" height="30" id="IsUserName" style="display:none;">
			<td colspan="3" bgcolor="#ffffff" class="STYLE6">
				<div align="left" style="padding-left: 50px;">
					<span class="STYLE10" id="IsUserName1">
					</span>
				</div>
			</td>
		</tr>
		<tr bgcolor="#ffffff" height="30">
			<td width="14%" class="STYLE6">
				<div align="center">
					<span class="STYLE10">用户密码：</span>
				</div>
			</td>
			<td width="34%" class="STYLE6">
				<div align="left">
					<span class="STYLE10" style="margin-left: 15px;"> <input
							type="password" value="" id="PassWord" maxlength="32" size="30"
							name="staff.PassWord"> </span>
				</div>
			</td>
			<td width="52%" class="STYLE6">
				<div align="left">
					<span class="STYLE10" style="margin-left: 15px;">（留空则不修改，只能用'0-9a-zA-Z.@_!'，6-20位，以内范围的字符）</span>
				</div>
			</td>
		</tr>
		<tr bgcolor="#ffffff" height="30" id="IsPassWord" style="display:none;">
			<td colspan="3" bgcolor="#ffffff" class="STYLE6">
				<div align="left" style="padding-left: 50px;">
					<span class="STYLE10" id="IsPassWord1">
					</span>
				</div>
			</td>
		</tr>
		<tr bgcolor="#ffffff" height="30">
			<td width="14%" class="STYLE6">
				<div align="center">
					<span class="STYLE10">确认密码：</span>
				</div>
			</td>
			<td width="34%" class="STYLE6">
				<div align="left">
					<span class="STYLE10" style="margin-left: 15px;"> <input
							type="password" id="NotPassWord" value="" maxlength="32" size="30"
							name="staff.NotPassWord"> </span>
				</div>
			</td>
			<td width="52%" class="STYLE6">
				<div align="left">
					<span class="STYLE10" style="margin-left: 15px;">（留空则不修改，只能用'0-9a-zA-Z.@_!'，6-20位，以内范围的字符）</span>
				</div>
			</td>
		</tr>
		<tr bgcolor="#ffffff" height="30" id="IsNotPassWord" style="display:none;">
			<td colspan="3" bgcolor="#ffffff" class="STYLE6">
				<div align="left" style="padding-left: 50px;">
					<span class="STYLE10" id="IsNotPassWord1">
					</span>
				</div>
			</td>
		</tr>
		<tr bgcolor="#ffffff" height="30">
			<td width="14%" class="STYLE6">
				<div align="center">
					<span class="STYLE10">用户类型：</span>
				</div>
			</td>
			<td width="34%" class="STYLE6">
				<div align="left">
					<span class="STYLE10" style="margin-left: 15px;"> 
					<select name="staff.Level">
							<s:iterator value="List" id="Level">
							<option value="<s:property value="#Level.LevelNum"/>" <s:if test="#contents.Level==#Level.LevelNum">selected</s:if>>
								<s:property value="#Level.Name"/>
							</option>
							</s:iterator>
					</select> 
					</span>
				</div>
			</td>
			<td width="52%" class="STYLE6">
				<div align="left">
					<span class="STYLE10" style="margin-left: 15px;">（选择用户的权限）</span>
				</div>
			</td>
		</tr>
		<tr bgcolor="#ffffff" height="30">
			<td width="14%" class="STYLE6">
				<div align="center">
					<span class="STYLE10">运行状态：</span>
				</div>
			</td>
			<td width="34%" class="STYLE6">
				<div align="left">
					<span class="STYLE10" style="margin-left: 15px;">			
					<s:if test="#contents.State==1">
						<input type="checkbox" name="State" checked="checked"> 
					</s:if>
					<s:if test="#contents.State==0">
						<input type="checkbox" name="State">
					</s:if>
					</span>
				</div>
			</td>
			<td width="52%" class="STYLE6">
				<div align="left">
					<span class="STYLE10" style="margin-left: 15px;">（勾选表示开启中，去掉则表示关闭中）</span>
				</div>
			</td>
		</tr>
		<tr bgcolor="#ffffff" height="30">
			<td width="14%" class="STYLE6">
				<div align="center">
					<span class="STYLE10">创建时间：</span>
				</div>
			</td>
			<td width="34%" class="STYLE6">
				<div align="left">
					<span class="STYLE10" style="margin-left: 15px;">
					 <s:property value="#contents.CreateTime"/>
					</span>
				</div>
			</td>
			<td width="52%" class="STYLE6">
				<div align="left">
					<span class="STYLE10" style="margin-left: 15px;">（员工新建的时间!）</span>
				</div>
			</td>
		</tr>
		<tr bgcolor="#ffffff" height="50">
			<td width="14%" class="STYLE6">
				<div align="center">
					<span class="STYLE10">使用说明：</span>
				</div>
			</td>
			<td width="34%" class="STYLE6">
				<div align="left">
					<span class="STYLE10" style="margin-left: 15px;"> 
					<textarea rows="5" cols="30" name="staff.Content" id="Content"><s:property value="#contents.Content" /></textarea>
					</span>
				</div>
			</td>
			<td width="52%" class="STYLE6">
				<div align="left">
					<span class="STYLE10" style="margin-left: 15px;">（不能留空，需要角色说明，说明不能小于6位）</span>
				</div>
			</td>
		</tr>
		<tr bgcolor="#ffffff" height="30">
			<td colspan="3" bgcolor="#ffffff" class="STYLE6">
				<div align="left" style="padding-left: 50px;">
					<span class="STYLE10"> <input type="submit" value="确定"
							name="send">&nbsp;&nbsp; <input type="button"
							value="关闭" onClick="window.close();" name="send"> </span>
				</div>
			</td>
		</tr>
		<tr bgcolor="#ffffff" height="30" id="IsSend" style="display:none;">
			<td colspan="3" bgcolor="#ffffff" class="STYLE6">
				<div align="left" style="padding-left: 50px;">
					<span class="STYLE10" id="IsSend1">
					</span>
				</div>
			</td>
		</tr>
	</table>
	</s:iterator>
	</td>
  </tr>
</table>
</body>
</html>